package com.example.smartcity_poverty.ui.AllService.LogisticsQuery.adapter

import android.content.Intent
import com.example.smartcity_poverty.App.Companion.url
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.logic.ServiceBean.LogisticsQueryBean.LqMoreModel
import com.example.smartcity_poverty.logic.util.Util.glide
import com.example.smartcity_poverty.logic.util.Util.show
import com.example.smartcity_poverty.ui.AllService.LogisticsQuery.activity.LqShowActivity
import kotlinx.android.synthetic.main.re_lq_iten_more.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *
 **/
class LqMoreAdapter(
    val size: Int,
    val list: MutableList<LqMoreModel.DataBean>,
    layoutId: Int
) : BaseRecyclerAdapter<LqMoreModel.DataBean>(list, layoutId) {
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: LqMoreModel.DataBean,
        position: Int,
        holder: BaseViewHolder
    ) {
        list.sortBy { it -> it.sort }
        val d = list[position]
        val con = holder.viewFind.view?.context

        glide(url + d.imgUrl, view.lqMoreImage)
        view.lqMoreTitle.text = d.name

        holder.itemView.setOnClickListener {
            con?.startActivity(
                Intent(con, LqShowActivity::class.java).putExtra(
                    "id",
                    d.id.toString()
                )
            )
        }

    }

    override fun getItemCount(): Int = size
}